package com.cqeec.waimaidemo.common;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Locale;
@Component
public class MyMetObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject){
        metaObject.setValue("createTime", LocalDateTime.now());
        metaObject.setValue("updateTime",LocalDateTime.now());
        metaObject.setValue("createUser",BaseContext.getThreadLocal());
        metaObject.setValue("updateUser",BaseContext.getThreadLocal());
    }
    @Override
    public void updateFill(MetaObject metaObject){
        metaObject.setValue("updateUser",BaseContext.getThreadLocal());
        metaObject.setValue("updateTime",LocalDateTime.now());
    }
}
